package com.WOWTradeNews.DataBase;

import java.io.ByteArrayOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import com.WOWTradeNews.Utils;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Parcel;
import android.os.Parcelable;

public class News extends Object implements Parcelable{
	String PK_ID;
	String title;
	String summary;//zaiyao
	String content;
	String type;
	String startDate;
	String endDate;
	String imageUrl;
	String attachmentUrl;
	String content2;
	String source;
	
	String acttime;
	String active;
	
	public String getActive() {
		return active;
	}

	public void setActive(String active) {
		this.active = active;
	}

	public String getActtime() {
		return acttime;
	}

	public void setActtime(String acttime) {
		this.acttime = acttime;
	}

	//AD?
	public int flag;
	
	private int adIid;
	private String adPath;
	private String adImgPath;
	private String adTitle;
	
	private boolean gj = false;
	private String note;
	private String gjtitle;
	private String gjContent;
	
	//news
	//iid subject contents sid datein down_date author intPublish country city news_link keywords
	//date_build is_post img1
	
	
	public String getGjContent() {
		return gjContent;
	}

	public void setGjContent(String gjContent) {
		this.gjContent = gjContent;
	}

	public String getGjtitle() {
		return gjtitle;
	}

	public void setGjtitle(String gjtitle) {
		this.gjtitle = gjtitle;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public boolean isGj() {
		return gj;
	}

	public void setGj(boolean gj) {
		this.gj = gj;
	}

	private String iid;
	private String subject;
	private String contents;
	private String sid;
	private String datein;
	private String down_date;
	private String author;
	private String intPublish;
	private String country;
	private String city;
	private String news_link;
	private String keyWords;
	private String date_build;
	private boolean is_post;
	private String img1Url;
	private String img2Url;
	private String img3Url;
	public String getImg2Url() {
		return img2Url;
	}

	public void setImg2Url(String img2Url) {
		this.img2Url = img2Url;
	}

	public String getImg3Url() {
		return img3Url;
	}

	public void setImg3Url(String img3Url) {
		this.img3Url = img3Url;
	}

	private String txt1Url;
	private int    newsType;
	private Bitmap img;
	
	private int id;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Bitmap getImg() {
		return img;
	}
	
	public void setImg(Bitmap bmp) {
		img = bmp;
	}
	
	public int getNewsType() {
		return this.newsType;
	}
	
	public void setNewsType(int newsType) {
		this.newsType = newsType;
	}
	
	public String getTxt1Url() {
		return this.txt1Url;
	}
	
	public void setTxt1Url(String txt1Url) {
		this.txt1Url = txt1Url;
	}
	
	public News() {
		flag = 0;
	}
	
	public String getPK_ID() {
		return PK_ID;
	}
	public void setPK_ID(String pK_ID) {
		PK_ID = pK_ID;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getSummary() {
		return summary;
	}
	public void setSummary(String summary) {
		this.summary = summary;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getStartDate() {
		return startDate;
	}
	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}
	public String getEndDate() {
		return endDate;
	}
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	public String getImageUrl() {
		return imageUrl;
	}
	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}
	public String getAttachmentUrl() {
		return attachmentUrl;
	}
	public void setAttachmentUrl(String attachmentUrl) {
		this.attachmentUrl = attachmentUrl;
	}
	public String getContent2() {
		return content2;
	}
	public void setContent2(String content2) {
		this.content2 = content2;
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
	
	public int getAdIid() {
		return this.adIid;
	}
	
	public void setAdIid(int iid) {
		this.adIid = iid;
	}
	
	public String getAdPath() {
		return this.adPath;
	}
	
	public void setAdPath(String path) {
		this.adPath = path;
	}
	
	public String getAdImgPath() {
		return this.adImgPath;
	}
	
	public void setAdImgPath(String path) {
		this.adImgPath = path;
	}
	
	public String getAdTitle() {
		return this.adTitle;
	}
	
	public void setAdTitle(String title) {
		this.adTitle = title;
	}
	
	
	//
	public String getIid() {
		return iid;
	}

	public void setIid(String iid) {
		this.iid = iid;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContents() {
		return contents;
	}

	public void setContents(String contents) {
		this.contents = contents;
	}

	public String getSid() {
		return sid;
	}

	public void setSid(String sid) {
		this.sid = sid;
	}

	public String getDatein() {
		return datein;
	}

	public void setDatein(String datein) {
		this.datein = datein;
	}

	public String getDown_date() {
		return down_date;
	}

	public void setDown_date(String down_date) {
		this.down_date = down_date;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getIntPublish() {
		return intPublish;
	}

	public void setIntPublish(String intPublish) {
		this.intPublish = intPublish;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getNews_link() {
		return news_link;
	}

	public void setNews_link(String news_link) {
		this.news_link = news_link;
	}

	public String getKeyWords() {
		return keyWords;
	}

	public void setKeyWords(String keyWords) {
		this.keyWords = keyWords;
	}

	public String getDate_build() {
		return date_build;
	}

	public void setDate_build(String date_build) {
		this.date_build = date_build;
	}

	public boolean isIs_post() {
		return is_post;
	}

	public void setIs_post(boolean is_post) {
		this.is_post = is_post;
	}

	public String getImg1Url() {
		return img1Url;
	}

	public void setImg1Url(String img1Url) {
		this.img1Url = img1Url;
		/*if(img1Url != null && !img1Url.equals("")) {
			img = Utils.getUrlBitmapBonus(img1Url);
		}*/
		
	}
	
	public List<String> getWordsList() {
		List<String> words = new ArrayList<String>();
		//keyWords.indexOf("")
		return words;
	}
	
	public static final Parcelable.Creator<News> CREATOR = new Creator<News>() {  
        public News createFromParcel(Parcel s) {  
        	/*
    		 * private String iid;
    	private String subject;
    	private String contents;
    	private String sid;
    	private String datein;
    	private String down_date;
    	private String author;
    	private String intPublish;
    	private String country;
    	private String city;
    	private String news_link;
    	private String keyWords;
    	private String date_build;
    	private boolean is_post;
    	private String img1Url;
    	private String txt1Url;
    	private int    newsType;
    	private Bitmap img;
    		 */
            News news = new News();
            news.setIid(s.readString());
            news.setSubject(s.readString());
            news.setContents(s.readString());
            news.setSid(s.readString());
            news.setDatein(s.readString());
            news.setDown_date(s.readString());
            news.setAuthor(s.readString());
            news.setIntPublish(s.readString());
            news.setCountry(s.readString());
            news.setCity(s.readString());
            news.setNews_link(s.readString());
            news.setKeyWords(s.readString());
            news.setDate_build(s.readString());
            news.setIs_post(s.readInt() == 1);
            news.setImg1Url(s.readString());
            news.setImg2Url(s.readString());
            news.setImg3Url(s.readString());
            news.setTxt1Url(s.readString());
            news.setNewsType(s.readInt());
            news.setActtime(s.readString());
            news.setActive(s.readString());
            try {
            	news.setImg(Bitmap.CREATOR.createFromParcel(s));
            } catch(Exception e) {
            	
            }
            
            return news;  
        }  
        public News[] newArray(int size) {  
            return new News[size];
        }  
    }; 

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel parcel, int arg1) {
		/*
		 * private String iid;
	private String subject;
	private String contents;
	private String sid;
	private String datein;
	private String down_date;
	private String author;
	private String intPublish;
	private String country;
	private String city;
	private String news_link;
	private String keyWords;
	private String date_build;
	private boolean is_post;
	private String img1Url;
	private String txt1Url;
	private int    newsType;
	private Bitmap img;
		 */
		parcel.writeString(iid);
		parcel.writeString(subject);
		parcel.writeString(contents);
		parcel.writeString(sid);
		parcel.writeString(datein);
		parcel.writeString(down_date);
		parcel.writeString(author);
		parcel.writeString(intPublish);
		parcel.writeString(country);
		parcel.writeString(city);
		parcel.writeString(news_link);
		parcel.writeString(keyWords);
		parcel.writeString(date_build);
		parcel.writeInt(is_post ? 1 : 0);
		parcel.writeString(img1Url);
		parcel.writeString(img2Url);
		parcel.writeString(img3Url);
		parcel.writeString(txt1Url);
		parcel.writeInt(newsType);
		parcel.writeString(acttime);
		parcel.writeString(active);
		if(img != null)img.writeToParcel(parcel, 0);
	}
	
}
